//ShiftExtraTile

#include "PUShiftExtraTile.h"
#include "Game.h"
#include "input.h"
#include "Controller.h"
#include "Player.h"
#include "ENUM.h"
#include "Text.h"

PUShiftExtraTile::PUShiftExtraTile()
{
	PU_name = "Shift Another Tile Power-Up";
}
PUShiftExtraTile::~PUShiftExtraTile(){}

int PUShiftExtraTile::Execute(Input* input, Player* player, Text* text)
{
	//set instructions
	text->setText("PLACE YOUR SECOND TILE!\n"
						"Hold <CTRL> for help.");
	if(input->KeyDown(DIK_LCONTROL) || input->KeyDown(DIK_RCONTROL))
	{
		text->setText(	"* Use <SHIFT> keys to look at your current goal.\n"
							"* Use A, D, Left arrow, or Right arrow keys to move extra tile.\n"
							"* Use W, S, Up arrow, or Down arrow keys to rotate extra tile.\n"
							"* Use <SPACE> to shift tile into board.\n");
	}

	Controller::Instance()->getBoard()->setCurrentTile(player->getCurrentTile());
	if(input->KeyPressed(DIK_A) || input->KeyPressed(DIK_LEFT))
		Controller::Instance()->getBoard()->shiftExtraPosDown();
	if(input->KeyPressed(DIK_D) || input->KeyPressed(DIK_RIGHT))
		Controller::Instance()->getBoard()->shiftExtraPosUp();
	if(input->KeyPressed(DIK_W) || input->KeyPressed(DIK_UP))
		Controller::Instance()->getBoard()->RotateExtraTileClock();
	if(input->KeyPressed(DIK_S) || input->KeyPressed(DIK_DOWN))
		Controller::Instance()->getBoard()->RotateExtraTileCounterClock();
	if(input->KeyPressed(DIK_SPACE))
	{
		Tile* tile = Controller::Instance()->getBoard()->boardShift();
		for(int i=0;i<NUM_PLAYERS;++i)
		{
			if(player[i].getCurrentTile() == Controller::Instance()->getBoard()
				->getExtraTile())
				player[i].SetBoardPosition(tile);
		}
		return MOVE;
	}
	return STAY;
}